package 第三章作业;

import java.io.*;

public class Work3 {
    public static void main(String[] args) {

        FileInputStream fis=null;
        DataInputStream dis=null;

        FileOutputStream fos=null;
        DataOutputStream dos=null;

        try {
            fis=new FileInputStream("F:\\java_senior_collection\\data\\Boy.jpeg");
            dis=new DataInputStream(fis);

            fos=new FileOutputStream("F:\\java_senior_collection\\doc\\NewBoy.jpeg");
            dos=new DataOutputStream(fos);
            int temp;
            while((temp=dis.read())!=-1){
                dos.write(temp);

            }
            System.out.println("图片copy成功");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                dis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                dos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
